#include "util/tc_common.h"
#include <iterator>
#include <sys/time.h>

using namespace std;
using namespace taf;

int main(int argc, char** argv)
{
    try
    {
        vector<string> v;
        v = TC_Common::sepstr<string>("|a|b||c|", "|", true);
        //cout << TC_Common::tostr(v.begin(), v.end(), "|") << endl;
        cout << v.size() << ":" << TC_Common::tostr(v) << endl;
        v = TC_Common::sepstr<string>("|a|b||c|", "|", false);
        cout << v.size() << ":" << TC_Common::tostr(v) << endl;

        string s = "asdfoasdfijfa";
        cout << s << endl;
        string s1 = TC_Common::bin2str(s);
        cout << s1 << endl;
        string s2 = TC_Common::bin2str(s, " ", 4);
        cout << s2 << endl;
        string s3 = TC_Common::str2bin(s1);
        cout << s3 << endl;
        string s4 = TC_Common::str2bin(s2, " ", 4);
        cout << s4 << endl;

        cout << "mathPeriod:" << TC_Common::matchPeriod("127.0.0.1", "127.*.*.*") << endl;

        cout << "[" << TC_Common::trim("abc\n\t") << "]" << endl;
        cout << "[" << TC_Common::trim("\r\nabc") << "]" << endl;
        cout << "[" << TC_Common::trim("\nabc\n") << "]" << endl;
        cout << "[" << TC_Common::trim(" abc "," \n\t") << "]" << endl;
        cout << "[" << TC_Common::trim("abcdefba", "ab", false) << "]" << endl;
        cout << "[" << TC_Common::trim("abcdefba", "ab") << "]" << endl;
        cout << "[" << TC_Common::trimleft("\nabc\n\t") << "]" << endl;

        cout << TC_Common::toSize("3K", 3000) << endl;
        cout << TC_Common::toSize("23M", 3000) << endl;
        cout << TC_Common::toSize("15G", 3000) << endl;
        cout << TC_Common::toSize("M", 3000) << endl;
        cout << TC_Common::toSize("34.32M", 3000) << endl;
        cout << TC_Common::toSize("3.2G", 3000) << endl;
        cout << TC_Common::toSize("3r,.2G", 3000) << endl;
        cout << TC_Common::toSize("mgmg", 3000) << endl;
       
    }
    catch (exception &ex)
    {
        cout << ex.what() << endl;
    }
    
    return 0;
}
